#include <bits/stdc++.h>
using namespace std;

int a[100010];
bool color[100010];
int n;
int ans=0;

void dfs(int d)
{
    if(d>n)
    {
        int sum=0;
        for(int i=1;i<=n;i++)
        {
            //cout<<color[i]<<" ";
            for(int j=i-1;j>=1;j--)
            {
                if(color[i]==color[j])
                {
                    if(a[i]==a[j])
                    {
                        sum+=a[i];
                        //cout<<sum<<" ";
                    }
                }
            }
        }
        ans=max(ans,sum);
        //cout<<endl;
        return;
    }
    for(int i=1;i<=2;i++)
    {
        color[d]=i;
        dfs(d+1);
    }
}

int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int t;
    cin>>t;
    while(t--)
    {
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
        }
        ans=0;
        dfs(1);
        memset(color,0,sizeof(color));
        cout<<ans<<endl;
    }
}
